<?php
if(!defined("_access") || _access!=1) die('禁止访问');
//服务器设置
date_default_timezone_set('Asia/Shanghai');
//error_reporting(0);
//权限设置
@session_start();
if(defined("_needlogin") && _needlogin && !isset($_SESSION['islogin'])){
	echo '<script>location.href="./login.php";</script>';
	die();
}
if(isset($_SESSION['islogin'])&&$_SESSION['islogin']==1){
//    $id = (int)$_SESSION['team']['id'];
//    $sql = "SELECT * from team where id='$id'";
//    $_SESSION['team'] = getOne($sql);

    $teamInfo = $_SESSION['team'];
}
//安全检测
if(!defined("_defend")){
	include_once 'defend.php';	
}

//db
$db = array();
//$db['host'] = '127.0.0.1';
//$db['port'] = '3306';
//$db['username'] = 'root';
//$db['password'] = 'xsz950123';
//$db['database'] = '2015KDCTF_platform';

$db['host']     = "localhost";
$db['port']     = "3306";
$db['username'] = "root";
$db['password'] = "";
$db['database'] = "CUMTCTF";
$link = mysql_connect($db['host'].':'.$db['port'], $db['username'], $db['password']);
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db($db['database']);
mysql_query("SET NAMES 'UTF8'");

function getOne($sql){
	$r = mysql_query($sql);
	if ($r) {
		return mysql_fetch_assoc($r);
	}
	return false;
}
function getAll($sql){
	$r = mysql_query($sql);
	$resultArr = array();
	if ($r) {
		while ($row = mysql_fetch_assoc($r)) {
			$resultArr[] = $row;
		}
		return $resultArr;
	}
	return false;
}
//处理默认参数

function SetDefault($name, $default, $type="GET"){

	if ($type == 'GET')
		return (isset($_GET[$name])&&!empty($_GET[$name]))?(int)$_GET[$name]:$default;
	else if($type == 'POST')
		return (isset($_POST[$name])&&!empty($_POST[$name]))?(int)$_POST[$name]:$default;
	else if($type == 'COOKIE')
		return (isset($_COOKIE[$name])&&!empty($_COOKIE[$name]))?(int)$_COOKIE[$name]:$default;

}





?>